package com.iccct.cloud.commons.result;

import java.util.List;
import com.iccct.cloud.commons.result.Response;

/**
 * @author iccct (taowutt1@gmail.com)
 * @since 2021-11-08  14:09
 */
public enum OKResponse {
    INSERT(20000, "插入成功"),
    DELETE(20000, "删除成功"),
    UPDATE(20000, "更新成功"),
    QUERY(20000, "查询成功"),
    IMPORT(20000, "导入成功"),
    UPLOAD_FILE(20000, "文件上传成功"),
    LOGIN(20000, "登录成功"),
    REGIST(20000, "注册成功"),
    LOGOUT(20000, "退出成功"),
    VALID(20000, "验证成功"),
    OK(20000, "成功"),
    CERTIFICATION_TRUE(20000, "实名认证成功,身份信息验证一致");

    private Integer code;
    private String msg;

    private OKResponse(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public <T> Response<T> toResponse(T data) {
        return data == null ? new Response(this.code, this.msg, (Object)null) : new Response(this.code, this.msg, data);
    }

    public Response toResponse() {
        return new Response(this.code, this.msg);
    }
}
